package main

import (
	"io/ioutil"
	"log"
	"net/http"
	"strings"
)

func main() {
	client := &http.Client{}
	url := "http://127.0.0.1:8989/jsonrpc"
	reqData := `{"id":0,"params":["button"],"method":"ClickService.Click"}`

	req, err := http.NewRequest("POST", url, strings.NewReader(reqData))
	if err != nil {
		log.Fatal(err)
	}

	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	rep, err := client.Do(req) //发起请求
	if err != nil {
		log.Fatal(err)
	}
	data, err := ioutil.ReadAll(rep.Body)
	defer rep.Body.Close()
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("receive data:%s", data) //2021/06/16 15:55:38 receive data:{"id":0,"result":"click button","error":null}
}
